Programming Raspberry Pi 3: Getting Started With Python (Programming Raspberry Pi 3, Raspberry Pi 3 User Guide, Python Programming, Raspberry Pi 3 with Python Programming) by UpSkill Learning

Programming Raspberry Pi 3: Getting Started With Python (Programming Raspberry Pi 3, Raspberry Pi 3 User Guide, Python Programming, Raspberry Pi 3 with Python Programming) by UpSkill Learning

Author:UpSkill Learning [Learning, UpSkill]
Language: eng
Format: azw3, epub, mobi, pdf
Publisher: UNKNOWN
Published: 2016-09-04T16:00:00+00:00


UPDATING LIST:

Updating the single or multiple elements of lists by giving the slice on the left-hand side of the assignment operator, and you can add to elements in a list by using the append() method.

List1 = [1, 2, 3, 'a', 'b', 'c']

print("Value available at index 2 : %s" % (List1[2]))

List1[2] = 4

print("New value available at index 2 : %s " % (List1[2]))

Output:

Value available at index 2 : 3

New value available at index 2 : 4

It seems both tuple and list looks similar, but both are different. List is mutable and tuples is immutable. The main difference between mutable and immutable is memory usage when you are trying to append an item. When you create a variable, some fixed memory is assigned to the variable. If it is a list, more memory is assigned than actually used.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.